﻿using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(UGUIRenderer))]
public class UGUIRendererEditor : Editor
{
    public override void OnInspectorGUI()
    {
        var renderer = target as UGUIRenderer;

        renderer.sprite = EditorGUILayout.ObjectField("Source Iamge", renderer.sprite, typeof(Sprite), true) as Sprite;
        renderer.color = EditorGUILayout.ColorField("Color", renderer.color);
        renderer.material = EditorGUILayout.ObjectField("Material", renderer.orginMaterial, typeof(Material), true) as Material;
        renderer.raycastTarget = EditorGUILayout.Toggle("Raycast Target", renderer.raycastTarget);

        renderer._TintColor = EditorGUILayout.ColorField("Tint Color", renderer._TintColor);

        renderer._MainTex = EditorGUILayout.ObjectField("Main Tex", renderer._MainTex, typeof(Texture), false) as Texture;
        renderer._MainTex_Scale = EditorGUILayout.Vector2Field("Main Tex Scale", renderer._MainTex_Scale);
        renderer._MainTex_Offset = EditorGUILayout.Vector2Field("Main Tex Offset", renderer._MainTex_Offset);

        renderer._Mask = EditorGUILayout.ObjectField("Mask", renderer._Mask, typeof(Texture), false) as Texture;
        renderer._Mask_Scale = EditorGUILayout.Vector2Field("Mask Scale", renderer._Mask_Scale);
        renderer._Mask_Offset = EditorGUILayout.Vector2Field("Mask Offset", renderer._Mask_Offset);

        renderer._HeatTime = EditorGUILayout.FloatField("_HeatTime", renderer._HeatTime);
        renderer._ForceX = EditorGUILayout.FloatField("_ForceX", renderer._ForceX);
        renderer._ForceY = EditorGUILayout.FloatField("_ForceY", renderer._ForceY);

        renderer._RenderQueue = EditorGUILayout.IntField("Render Queue", renderer._RenderQueue);

        EditorUtility.SetDirty(target);
        serializedObject.ApplyModifiedProperties();

        serializedObject.Update();
    }
}